<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Category Details</f:facet>


        <s:decorate id="label" template="layout/display.xhtml">
            <ui:define name="label">Label</ui:define>
            <h:outputText value="#{categoryHome.instance.label}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/CategoryEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty categoryFrom ? 'CategoryList' : categoryFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Parent</h:panelGroup>
        </f:facet>
    <div class="association" id="parentParent">

        <h:outputText value="There is no parent associated with this category."
                   rendered="#{categoryHome.instance.parent == null}"/>

        <rich:dataTable var="_category"
                   value="#{categoryHome.instance.parent}"
                rendered="#{categoryHome.instance.parent != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="parentTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_category.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Label</f:facet>
                <h:outputText value="#{_category.label}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Parent id</f:facet>
                <h:outputText value="#{_category.parent.id}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewcategory"
                     value="View"
                      view="/Category.xhtml">
                    <f:param name="categoryId"
                           value="#{_category.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Subcategories</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="subcategoriesChildren">

        <h:outputText value="There are no subcategories associated with this category."
                   rendered="#{empty categoryHome.subcategories}"/>

        <rich:dataTable value="#{categoryHome.subcategories}"
                       var="_category"
                  rendered="#{not empty categoryHome.subcategories}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="subcategoriesTable">
            <rich:column sortBy="#{_category.id}">
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_category.id}"/>
            </rich:column>
            <rich:column sortBy="#{_category.label}">
                <f:facet name="header">Label</f:facet>
                <h:outputText value="#{_category.label}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectcategory"
                     value="Select"
                      view="/Category.xhtml">
                    <f:param name="categoryId"
                            value="#{_category.id}"/>
                    <f:param name="categoryFrom" value="Category"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add category"
                view="/CategoryEdit.xhtml">
            <f:param name="categoryId"
                    value="#{categoryHome.instance.id}"/>
            <f:param name="categoryFrom" value="Category"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
